import {
  Controller,
  Get,
  Post,
  Put,
  Delete,
  Param,
  Body,
} from '@nestjs/common';
import { PaperService } from './paper.service';
import { Paper } from './paper.schema';

@Controller('paper')
export class PaperController {
  constructor(private readonly papersService: PaperService) {}

  @Get()
  async getAllPapers() {
    return this.papersService.getAllPapers();
  }

  @Get(':id')
  async getPaperById(@Param('id') id: string) {
    return this.papersService.getPaperById(id);
  }

  @Post()
  async createPaper(@Body() paper: Paper) {
    return this.papersService.createPaper(paper);
  }

  @Put(':id')
  async updatePaper(
    @Param('id') id: string,
    @Body() paper: Paper,
  ): Promise<Paper> {
    return this.papersService.updatePaper(id, paper);
  }

  @Delete(':id')
  async deletePaper(@Param('id') id: string) {
    return this.papersService.deletePaper(id);
  }
}
